/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import Entity.Etbl_Country;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author MrKoi
 */
public class BaseConnection {
    private static String url="jdbc:sqlserver://";
    private static String servName="localhost";
    private static String dbName="East2west_tours_and_travels";
    private static String username="sa";
    private static String password="123456";
    protected static Connection cnn=null;
    
    public static  String getConnectionString(){
        return url+servName+";databaseName="+dbName;
    }
    
    public static void getConnection(){        
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            cnn=DriverManager.getConnection(getConnectionString(),username,password);
            if(cnn!=null){
                System.out.println("co^ nec\" su*n` suc set...");
            }else{
                System.out.println("co^ nec\" su*n` pheo...");
            }
        } catch (SQLException ex) {
            Logger.getLogger(BaseConnection.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(BaseConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public BaseConnection() {
        //cnn=this.getConnection();
    }
    
    protected void releaseConnection() throws SQLException {
        try {
            cnn.close();
        } catch (SQLException ex) {
        }
    }      
    
    public static void main(String[]a){
        BaseConnection objDB=new BaseConnection();      
        DALTotalPageIndex.getTotalPage("tbl_Flights", "", 4);
        System.out.println("a: "+DALTotalPageIndex.TotalPage);  
        DALtbl_Country objCountry=new DALtbl_Country();
           Etbl_Country objC=new Etbl_Country(4, "Korea", null);
           System.out.println(objCountry.Addtbl_Country(objC));
    }
    
}
